package base.mvc.section {
	import flash.display.MovieClip;
	import base.dspObj.DoOperations;
	
	public class ViewSection extends MovieClip implements IViewSection {
		
		protected var arrInnerAnimElements: Array;
		
		public function ViewSection(): void {}
		
		public function init(): void {
			this.stop();
			if (this.arrInnerAnimElements != null) for (var i:uint = 0; i < this.arrInnerAnimElements.length; i++)
				MovieClip(this.arrInnerAnimElements[i]).stop();
		}
		
		private function createArrInnerAnimElements(): void {
			this.arrInnerAnimElements = new Array();
		}
		
		public function show(): void {
			DoOperations.playToFrame(this, this.totalFrames, this.startAfterShow, this);
			if (this.arrInnerAnimElements != null) for (var i: uint = 0; i < this.arrInnerAnimElements.length; i++) {
				DoOperations.playToFrame(MovieClip(this.arrInnerAnimElements[i]), this.totalFrames);
				if (this.arrInnerAnimElements[i].show != null) this.arrInnerAnimElements[i].show();
			}
		}
		
		public function startAfterShow(): void {
			ViewSectionManager.startSection(false);
			//abstrakcyjna, np. dodatkowe animacje, dodawanie zdarzeń myszy
		}
		
		public function stopBeforeHide(): void {
			//abstrakcyjna, np. dodatkowe animacje, usuwanie zdarzeń myszy
		}
		
		public function hide(): void {
			this.stopBeforeHide();
			DoOperations.playToFrame(this, 1, this.hideComplete, this);
			if (this.arrInnerAnimElements != null) for (var i: uint = 0; i < this.arrInnerAnimElements.length; i++) {
				DoOperations.playToFrame(MovieClip(this.arrInnerAnimElements[i]), 1);
				if (this.arrInnerAnimElements[i].hide != null) this.arrInnerAnimElements[i].hide();
			}
		}
		
		public function hideComplete(): void {
			ViewSectionManager.finishStopSection();
		}
		
	}

}